package best.driver.android;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.widget.Toast;

public class AppInfo {


	public static final String SP_FILE = "best_new";

    public enum ContextMode {
        TEST, ONLINE
    }

    public enum AutomationMode {
        TEST, ONLINE
    }

    public static final ContextMode currentContextMode = ContextMode.TEST;
    public static final AutomationMode currentAutomationMode = AutomationMode.ONLINE;



	public static String getDeviceName() {
        StringBuilder buffer = new StringBuilder();
        buffer.append(android.os.Build.MANUFACTURER).append("-").append(android.os.Build.MODEL);
        buffer.append("(").append(getDeviceOSVersion()).append(")");
        return buffer.toString();
    }

    public static String getDeviceOSVersion() {
        return android.os.Build.VERSION.RELEASE;
    }

    public static String getAppVersion() {
        try {
            PackageManager packageManager = BestApp.getInstance().getPackageManager();
            PackageInfo packInfo = packageManager.getPackageInfo(BestApp.getInstance().getPackageName(), 0);
            String version = packInfo.versionName;
            return version;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return "3.3.0";
    }

    /**
     * 显示提示信息
     *
     * @param context
     *            : 行下文环境
     * @param message
     *            ： 显示的信息
     * @category This method must called in the UI-Thread.
     */
    public static void showToast(Context context, String message) {
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
    }

    public static void showToast(Context context, int resid) {
        Toast.makeText(context, resid, Toast.LENGTH_SHORT).show();
    }

}
